<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateTopicsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('topics', function (Blueprint $table) {
            $table->increments('id');
            $table->string('key')->comment('唯一码')->unique();
            $table->integer('type')->default(1)->comment('类型');
            $table->string('title')->nullable()->comment('标题')->index();
            $table->integer('uid')->comment('用户ID')->index();
            $table->integer('fid')->default(-1)->comment('版块ID')->index();
            $table->integer('sensitivity')->default(100)->comment('敏感度');
            $table->integer('weight')->default(0)->comment('权重')->index();
            $table->integer('view_count')->default(0)->comment('阅读数')->index();
            $table->integer('comment_count')->default(0)->comment('评论(回复)数')->index();
            $table->integer('last_comment_time')->default(0)->comment('最后评论时间')->index();
            $table->integer('last_comment_id')->default(0)->comment('最后评论ID');
            $table->dateTime('action_time')->nullable()->comment('出击时间');
            $table->string('action_province')->nullable()->comment('省份');
            $table->string('action_city')->nullable()->comment('城市');
            $table->string('action_district')->nullable()->comment('区域');
            $table->string('action_location')->nullable()->comment('出击地点');
            $table->decimal('action_longitude', 10, 6)->nullable()->comment('经度');
            $table->decimal('action_latitude', 10, 6)->nullable()->comment('纬度');
            $table->bigInteger('mask_code')->default(0)->comment('掩码');
            $table->timestamps();
            $table->softDeletes();

        });
        \DB::statement("ALTER TABLE `topics` AUTO_INCREMENT = 10001, comment = '帖子表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('topics');
    }
}
